package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ly
 * @Date: 2021/07/14/19:08
 * @Description:
 */
@RestController
@RequestMapping("/a")
public class UserController {

    @Reference
    private UserService userService;


    @GetMapping("/{page}/{size}")
    public PageInfo<User> getAll(@PathVariable int page,@PathVariable int size){
        return userService.findAll( page, size);
    }



    @GetMapping("/{id}")
    public  User  get(@PathVariable  Integer id){
        return  userService.findById(id);
    }



    @PostMapping
    public  Integer AddUser (User user){
        return  userService.addUser(user);
    }



    @DeleteMapping("/{id}")
    public Integer DeleteUser(@PathVariable  Integer id){
        return userService.deleteUser(id);
    }



    @PutMapping
    public Integer UpdateUser(User user){
        return  userService.updateUser(user);
    }

}
